//
// Created by gj on 16-1-31.
//

#ifndef ALLUTILS_CCLASSINFO_H
#define ALLUTILS_CCLASSINFO_H

#include "CObject.h"

#include <string>

using namespace std;

class CClassInformation : public CObject {
public:
    enum EClassInfoType {
        eClass, eInherit, eMultipleInherit
    };

    explicit CClassInformation(const char *className) //
            : className(className == NULL ? "null" : className), classInfoType(eClass) {
        //
    }

    const string &getClassName() const {
        return className;
    }

    EClassInfoType getClassInfoType() const {
        return classInfoType;
    }


    virtual ~CClassInformation() {
    }

protected:
    const string className;
    const EClassInfoType classInfoType;

    explicit CClassInformation(const char *className, EClassInfoType classInfoType) //
            : className(className == NULL ? "null" : className), classInfoType(classInfoType) {
    }
};

class CClassInheritInformation : public CClassInformation {
public:
    explicit CClassInheritInformation(const char *className, const CClassInformation &parentClassInfo) //
            : CClassInformation(className, eInherit), parentClassInformation(parentClassInfo) {
    }

    const CClassInformation &getParentClassInformation() const {
        return parentClassInformation;
    }

protected:
    const CClassInformation &parentClassInformation;
};


class CClassMultipleInheritInformation : public CClassInformation {
public:
    explicit CClassMultipleInheritInformation(const char *className, //
                                              const CClassInformation **parentClassInformation, //
                                              const int parentClassCount) //
            : CClassInformation(className, eMultipleInherit), //
              parentClassCount(parentClassCount), //
              parentClassInformation(parentClassInformation) {
    }

    int getParentClassCount() const {
        return parentClassCount;
    }

    const CClassInformation **getParentClassInformation() {
        return parentClassInformation;
    }

    virtual ~CClassMultipleInheritInformation() {
        if (parentClassInformation != NULL) {
            delete[] parentClassInformation;
        }
    }

protected:
    const int parentClassCount;
    const CClassInformation **parentClassInformation;
};

#endif //ALLUTILS_CCLASSINFO_H
